<?php
session_start();
// session_register('admin');
include "../dbconnect.inc.php";
  if($_POST){
      $email=$_POST['email'];
      $password=$_POST['password'];
      $sql=mysql_query("select * from admin where email='$email' and password='$password'");
      $res=mysql_num_rows($sql); 
        if($res>0){
            $rs_login=mysql_fetch_assoc($sql);
            $id=$rs_login['id'];
            $email=$rs_login['email'];
            $firma=$rs_login['firma'];
            $now = date("Y-m-d H:i:s");
            $_SESSION['adminlogin']['id']=$id;
            $_SESSION['adminlogin']['email']=$email;
            $_SESSION['adminlogin']['firma']=$firma;
            $_SESSION['adminlogin']['lastlogin']=$rs_login['lastlogin'];  
            $sql=mysql_query("UPDATE admin SET lastlogin='$now' where id='$id'");
            echo "Erfolgreich";
        } else {
            echo "<font style=\"color:red;\">Benutzername oder Password falsch!</font>";
       }
   }
?>